package com.api.shopapi.mapper;

import com.api.shopapi.entity.Error;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ErrorMapper {

    @Insert("insert into error" +
            "(" +
            "ErrorCode," +
            "Url," +
            "Param," +
            "Message," +
            "Type," +
            "CreateTime" +
            ") " +
            "values" +
            "(" +
            "#{error.ErrorCode}," +
            "#{error.Url}," +
            "#{error.Param}," +
            "#{error.Message}," +
            "#{error.Type}," +
            "#{error.CreateTime}" +
            ")")
    int insert(@Param("error") Error error);


    @Select("select * from error order by CreateTime desc")
    List<Error> getList();

}
